<?php

namespace Chat\Model\Entity;

class User {
	
	protected $user_id = null;
	
	protected $username = null;
	
	protected $email = null;
	
	protected $display_name = null;
	
	protected $isOnline = null;
	
	public function getUserID(){
		return $this->user_id;
		}
		
		public function getUsername(){
			return $this->username;
		}
		
		public function getEmail(){
			return $this->email;
		}
		
		public function getDisplayName(){
			return $this->display_name;
		}
		
		public function getIsOnline(){
			return $this->isOnline;
		}
		
		public function setUserName($username){
			$this->username = $username;
		}
		
		public function setEmail($email){
			$this->email = $email;
		}
		
		public function setDisplayName($displayName){
			$this->display_name = $displayName;
		}
		
		public function setIsOnline($isOnline){
			$this->isOnline = $isOnline;
		}
		
public function setUserID($userID){
			$this->user_id = $userID;
		}
		
		
	
	public function __construct(array $options = null) {
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function setOptions(array $options) {
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	public function __set($name, $value) {
		$method = 'set' . $name;
		if (!method_exists($this, $method)) {
			throw new Exception('Invalid Method');
		}
		$this->$method($value);
	}
	
	public function __get($name) {
		$method = 'get' . $name;
		if (!method_exists($this, $method)) {
			throw new Exception('Invalid Method');
		}
		return $this->$method();
	}
	
}